# -*- coding: UTF-8 -*-
'''
Created on 16/10/2014

@author: Eduardo Cardeira - Num 6033

Exemplo 9 da Aula Teorica 4

'''
from mmap import mmap, ACCESS_READ
from xlrd import open_workbook

print open_workbook('simple.xls')
with open('simple.xls', 'rb') as f:
    print open_workbook(file_contents=mmap(f.fileno(), 0, access=ACCESS_READ))
aString = open('simple.xls', 'rb').read()
print open_workbook(file_contents=aString)

wb = open_workbook('simple.xls')
for s in wb.sheets():
    print 'Folha:', s.name
    print "linhas = ", s.nrows, "colunas = ", s.ncols
    for row in range(s.nrows):
        values = []
        for col in range(s.ncols):
            values.append(s.cell(row, col).value)
        print ','.join(values)
    print
